<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    /* 
        函数在作用域，在函数创建时就已经确定的（词法作用域）  和调用位置无关

    */
    let a = "全局变量a";
    function fn() {
      console.log(a);
    }
    function fn2() {
      let a = "fn2中的a";
      fn();
    }
    fn2();

    function fn3() {
      let a = "fn3中的a";
      return function fn4() {
        console.log(a);
      };
    }
    let res = fn3();
    res();
  </script>
</html>
